package com.zzyl.controller.manager;

import com.zzyl.base.PageBean;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.dto.NursingLevelPageQueryDto;
import com.zzyl.entity.NursingLevel;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级管理")
@Slf4j
public class NursingLevelController {
    @Autowired
    private NursingLevelService nursingLevelService;

    /**
     * 分页查询护理等级信息
     * @param dto
     * @return
     */
    @ApiOperation("分页查询护理等级信息")
    @GetMapping("/listByPage")
    public ResponseResult pageBean(NursingLevelPageQueryDto dto){
        PageBean<NursingLevelVo> page =  nursingLevelService.pageBean(dto);
        return ResponseResult.success(page);
    }

    /**
     * 插入护理等级信息
     * @param dto
     * @return
     */
    @ApiOperation("插入护理等级信息")
    @PostMapping("/insert")
    public ResponseResult insert(@RequestBody NursingLevelDto dto){
        nursingLevelService.insert(dto);
        return ResponseResult.success();
    }
    /**
     * 根据ID查询护理等级信息
     */
    @ApiOperation("根据ID查询护理等级信息")
    @GetMapping("/{id}")
    public ResponseResult getById(@PathVariable Long id){
        NursingLevelVo nursingLevelVo = nursingLevelService.getById(id);
        return ResponseResult.success(nursingLevelVo);
    }
    /**
     * 更新护理等级信息
     */
    @ApiOperation("更新护理等级信息")
    @PutMapping("/update")
    public ResponseResult update(@RequestBody NursingLevelDto dto){
        nursingLevelService.update(dto);
        return ResponseResult.success();
    }
    /**
     * 删除护理等级信息
     */
    @ApiOperation("删除护理等级信息")
    @DeleteMapping("/delete/{id}")
    public ResponseResult delete(@PathVariable Long id){
        nursingLevelService.delete(id);
        return ResponseResult.success();
    }
    /**
     * 启用、禁用护理等级
     */
    @ApiOperation("启用、禁用护理等级")
    @PutMapping("/{id}/status/{status}")
    public ResponseResult startOrStop(@PathVariable Long id,
                                      @PathVariable Integer status){
        nursingLevelService.startOrStop(id,status);
        return ResponseResult.success();
    }
    /**
     * 查询所有护理等级信息
     */
    @ApiOperation("查询所有护理等级信息")
    @GetMapping("/listAll")
    public ResponseResult getAll(){
        List<NursingLevelVo> list = nursingLevelService.getAll();
        return ResponseResult.success(list);

    }
}